var ExtractPlugin = require('extract-text-webpack-plugin')
var webpack = require('webpack')


module.exports = {
    entry: {    
        entry : './index.js',
        vendor: ['react', 'react-dom']
    },
    output: {   
        path: __dirname + '/public',
        publicPath: '/',
        filename: '[name].js'
    },
    resolve: {
        extensions: ['.js', '.jsx','style', '.less']
    },
    module: {
        loaders: [{
            test: /\.js$/,
            exclude: /node_modules/,
            loader: 'babel-loader',
            query: {
                presets: ['react', 'env'],
            } 
        }, {
            test: /\.less$/,
            exclude: /node_modules/,
            use: ExtractPlugin.extract({
                fallback: 'style-loader',
                use: ['css-loader','less-loader']
            })
        }, {  
            test: /\.css$/,  
            use: ['style-loader', 'css-loader']  
        }]
    },
    plugins: [
        new webpack.optimize.CommonsChunkPlugin({
            name: 'vendor',
            chunks: 'vendor'
        }),
        new ExtractPlugin('bundle.css')
    ]
}
